package org.smart4j.framework.dwtest.simplproxy;

import java.lang.reflect.Proxy;

/**
 * Created by
 *
 * @author dw
 * @date 2018/01/24
 */
public class HelloMain {
    public static void main(String[] args) {
        Hello h = new HelloImp();

        System.out.println("静态proxy");

        HelloProxy helloProxy = new HelloProxy();
        helloProxy.say();

        System.out.println("动态proxy");
        DynamicProxy dynamicProxy = new DynamicProxy(h);
        Hello hdynamic = (Hello) Proxy.newProxyInstance(h.getClass().getClassLoader(), h.getClass().getInterfaces(), dynamicProxy);
        hdynamic.say();

        System.out.println("cglib动态代理proxy");
        Hello hellocglib = CglibProxy.getInstance().getProxy(HelloImp.class);
        hellocglib.say();

    }
}
